home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Developer Toolbox 6.1
/
SGI Developer Toolbox 6.1 - Disc 3.iso
/
bin
/
installServer
< prev
next >
Wrap
Text File
|
1996-11-11
|
12KB
|
366 lines
#!/bin/csh -f
set path = (/usr/bsd /bin /usr/bin /usr/sbin /usr/bin/X11)
#
# update path to also look in the same directory from where this script
# was executed from
#
set DT_xconfirm = "$DT_utilities/DT_xconfirm"
set TLINK = "/usr/sbin/tlink"
set path = (${DT_util_path} $path)
# make sure CDROM_ROOT envariable is set
if (! $?CDROM_ROOT) then
$DT_xconfirm notviewDT
exit 1
endif
#
# see if our server is running
#
isServerRunning
if ($status == 1) then
$DT_xconfirm warn "Server is already running."
exit 2
endif
#
# determine a reasonable tmp dir location
#
if ($?TMPDIR) then
set tmpDir = $TMPDIR
else
if ( -e /tmp) then
set tmpDir = /tmp
else if ( -e /usr/tmp ) then
set tmpDir = /usr/tmp
else
$DT_xconfirm error "Directories /tmp and /usr/tmp are missing.\
Please set environment variable TMPDIR\
to be an alternate temp directory and retry."
exit 0
endif
endif
#
# find out the location of CDROM
#
# inherited from CDROM_ROOT envariable
set dt_utilities = $HOME/$DT_WWW_ROOT/DT_utilities
set htdocs = $HOME/$DT_WWW_ROOT/htdocs
set conf = $HOME/$DT_WWW_ROOT/conf
set logs = $HOME/$DT_WWW_ROOT/logs
set cgi_bin = $HOME/$DT_WWW_ROOT/cgi-bin
set icons = $HOME/$DT_WWW_ROOT/icons
set DT_DocRootFile = $HOME/$DT_WWW_ROOT/.DT_DocRootFile
set DT_OksvrRoot = $HOME/$DT_WWW_ROOT/.DT_OksvrRoot
set dtcdresource = $HOME/$DT_WWW_ROOT/.dtcdresource
set perm_dtcdres = $HOME/.dtcdresource
set rm = /usr/bin/rm
#
# now see if the www environment has been configured before
# make sure the www environment is correctly conditioned
#
# remove old DT_utilities link
if ( -e $dt_utilities ) $rm -r $dt_utilities
ln -s $DT_utilities $dt_utilities
/usr/bin/mkdir -p $htdocs
# remove old htdocs files
if ( -e $htdocs ) $rm -r $htdocs
/usr/bin/mkdir -p $htdocs
# make dtcdresource, if necessary
# cd number set to -1 to force read of actual title
touch $perm_dtcdres
(echo "$htdocs\n$CDROM_ROOT/ -1"; grep -v $CDROM_ROOT $perm_dtcdres) > $dtcdresource
# clean old conf files
if ( -e $conf ) $rm -r $conf
/usr/bin/mkdir $conf
# remove old logs files
if ( -e $HOME/$DT_WWW_ROOT/logs ) $rm -r $HOME/$DT_WWW_ROOT/logs
/usr/bin/mkdir $HOME/$DT_WWW_ROOT/logs
/usr/bin/chmod +w $HOME/$DT_WWW_ROOT/logs
# remove old links if any
#echo Cleaning up old links
if ( -e $cgi_bin ) $rm -r $cgi_bin
if ( -e $icons ) $rm -r $icons
# remove .DT_* files
if ( -e $DT_DocRootFile ) $rm $DT_DocRootFile
if ( -e $DT_OksvrRoot ) $rm $DT_OksvrRoot
# create these files to set rw permissions
/usr/bin/touch $HOME/$DT_WWW_ROOT/logs/{access_log,agent_log,error_log,referer_log}
/usr/bin/chmod +rw $HOME/$DT_WWW_ROOT/logs/{access_log,agent_log,error_log,referer_log}
#
# set up new links - create "virtual document root"
#
#echo Setting up new links
set DTglobl = "toolbox"
set DTcdspace = "cdspace"
#$DT_utilities/linkChunks $htdocs $DTcdspace
$CDROM_ROOT/bin/linkChunks $htdocs $DTcdspace
set this_CD = `grep "id" $CDROM_ROOT/.IM | head -1 | sed -e 's/^[^"]*"//' -e 's/"[^"]*$//'`
pushd $htdocs >& /dev/null
@ i = 0
foreach n ($DT_BASE_CDs)
mkdir -p ext_cd$n/cd$i
/usr/bin/ln -s ext_cd$n cd$i
rm -rf ext_cd$n
@ i = $i + 1
end
LinkCdResource $htdocs "$HOME/$DT_WWW_ROOT" $this_CD
#/usr/bin/ln -s $CDROM_ROOT ext_cd$this_CD
/usr/bin/ln -s ext_cd$this_CD/toolbox $DTglobl
popd >& /dev/null
# files of augment directories override any corresponding files of main dir
# however the need for such override should be small
# do directories which are tlinks, i.e. either/or files
foreach subdir (cgi-bin icons)
if ($DT_NHLPERS > 0) then
foreach dir ($DT_HELPERS)
set d = $DT_utilities/$dir/$subdir
if (-d $d) $TLINK $d $HOME/$DT_WWW_ROOT/$subdir
end
endif
$TLINK $DT_utilities/$subdir $HOME/$DT_WWW_ROOT/$subdir
end
# do directories which are copies, i.e. concatenations from all sources
foreach subdir (conf)
mkdir -p $HOME/$DT_WWW_ROOT/$subdir >& /dev/null
pushd $DT_utilities/$subdir >& /dev/null
foreach f (*)
cp $f $HOME/$DT_WWW_ROOT/$subdir
end
popd >& /dev/null
if ($DT_NHLPERS > 0) then
foreach dir ($DT_HELPERS)
if (! -d $DT_utilities/$dir/$subdir) continue
pushd $DT_utilities/$dir/$subdir >& /dev/null
foreach f (*)
touch $HOME/$DT_WWW_ROOT/$subdir/$f
cat $f >> $HOME/$DT_WWW_ROOT/$subdir/$f
end
popd >& /dev/null
end
endif
end
/usr/bin/cp $CDROM_ROOT/index.html $htdocs/.
/usr/bin/ln -s $tmpDir $htdocs/tmp
/usr/bin/cp $DT_utilities/dtCDmgr $htdocs
#
# this is essentially the ServerRoot
#
set wwwRoot = $HOME/$DT_WWW_ROOT
#
# create .DT_* files
#
/usr/bin/touch $DT_DocRootFile
echo \$DocumentRoot=\"$wwwRoot/htdocs\" > $DT_DocRootFile
chmod +rw $DT_DocRootFile
/usr/bin/touch $DT_OksvrRoot
echo \$OksvrSearchRoot=\"$wwwRoot/htdocs/toolbox/searchtools\" > $DT_OksvrRoot
chmod +rw $DT_OksvrRoot
#
# establish a free port number for the http server
#
#
# see if it is locked by someone else
#
while ( -e /tmp/.portlock )
echo "trying to obtain port number for http server, please wait"
sleep 1
end
# lock the port number until the server actually starts
/usr/bin/mkdir /tmp/.portlock
/usr/bin/chmod og-r /tmp/.portlock
set sockPort = `getFreePortNumber 8080`
if ($sockPort == -1) then
$DT_xconfirm error "Could not find a free port for webserver."
exit 0
endif
#
# store it in a file
#
/usr/bin/touch $HOME/$DT_WWW_ROOT/logs/httpd.port
echo $sockPort > $HOME/$DT_WWW_ROOT/logs/httpd.port
#
# create a file in tmpDir which is port specific
# we can store user home location, to be used by cgi-bin script
#
#
# note : have to rely on /tmp here ???
#
if (-e /tmp/.userhome_$sockPort) $rm -f /tmp/.userhome_$sockPort
touch /tmp/.userhome_$sockPort
echo \$userHome=\"$HOME\" > /tmp/.userhome_$sockPort
/usr/bin/chmod +rw /tmp/.userhome_$sockPort
if (-e /tmp/.userhome_$CDROM_ROOT) $rm -f /tmp/.cdlocation_$sockPort
touch /tmp/.cdlocation_$sockPort
echo -n \$CDROM_ROOT=\"$CDROM_ROOT\" > /tmp/.cdlocation_$sockPort
echo ";" >> /tmp/.cdlocation_$sockPort
echo -n \$cdromMount=\"\$CDROM_ROOT\" >> /tmp/.cdlocation_$sockPort
echo ";" >> /tmp/.cdlocation_$sockPort
/usr/bin/chmod +rw /tmp/.cdlocation_$sockPort
#
# at this point we have $DT_WWW_ROOT environment with right links
#
# create conf files
#
# access.conf
#
set accessConf = $conf/access.conf
/usr/bin/touch $accessConf
/usr/bin/chmod +rw $accessConf
echo "# " > $accessConf
echo "<Directory $wwwRoot/cgi-bin> " >> $accessConf
echo " Options Indexes FollowSymLinks " >> $accessConf
echo "</Directory> " >> $accessConf
echo " " >> $accessConf
echo "<Directory $wwwRoot/htdocs> " >> $accessConf
echo " Options All " >> $accessConf
echo " AllowOverride All " >> $accessConf
echo " " >> $accessConf
echo " <Limit GET> " >> $accessConf
echo " order allow,deny " >> $accessConf
echo " allow from all " >> $accessConf
echo " </Limit> " >> $accessConf
echo "</Directory> " >> $accessConf
#
# srm.conf
#
set srmConf = $conf/srm.conf
/usr/bin/touch $srmConf
/usr/bin/chmod +rw $srmConf
echo \# > $srmConf
echo DocumentRoot $wwwRoot/htdocs >> $srmConf
echo >> $srmConf
echo UserDir public_html >> $srmConf
echo >> $srmConf
echo DirectoryIndex index.html >> $srmConf
echo >> $srmConf
echo FancyIndexing on >> $srmConf
echo >> $srmConf
echo AddIconByType \(TXT,/icons/text.xbm\) text/\* >> $srmConf
echo AddIconByType \(IMG,/icons/image.xbm\) image/\* >> $srmConf
echo AddIconByType \(SND,/icons/sound.xbm\) audio/\* >> $srmConf
echo AddIcon /icons/movie.xbm .mpg .qt >> $srmConf
echo AddIcon /icons/binary.xbm .bin >> $srmConf
echo >> $srmConf
echo AddIcon /icons/back.xbm .. >> $srmConf
echo AddIcon /icons/menu.xbm ^^DIRECTORY^^ >> $srmConf
echo AddIcon /icons/blank.xbm ^^BLANKICON^^ >> $srmConf
echo >> $srmConf
echo DefaultIcon /icons/unknown.xbm >> $srmConf
echo >> $srmConf
echo ReadmeName README >> $srmConf
echo HeaderName HEADER >> $srmConf
echo >> $srmConf
echo IndexIgnore \*/\.\?\?\* \*~ \*\# \*/HEADER\* \*/README\* >> $srmConf
echo >> $srmConf
echo AccessFileName .htaccess >> $srmConf
echo >> $srmConf
echo DefaultType text/plain >> $srmConf
echo >> $srmConf
echo AddEncoding x-compress Z >> $srmConf
echo AddEncoding x-gzip gz >> $srmConf
echo >> $srmConf
echo ScriptAlias /cgi-bin/ $wwwRoot/cgi-bin/ >> $srmConf
echo ScriptAlias /toolbox/www/cgi-bin/ $wwwRoot/cgi-bin/ >> $srmConf
echo >> $srmConf
echo AddType text/x-server-parsed-html .html >> $srmConf
echo AddType text/x-server-parsed-html .shtml >> $srmConf
echo AddType application/x-httpd-cgi .cgi >> $srmConf
echo AddType application/x-httpd-cgi -cgi >> $srmConf
echo AddType application/x-httpd-cgi .pl >> $srmConf
if ($DT_domain == "") then
set mydomain = ""
else
set mydomain = ".$DT_domain"
endif
#
# httpd.conf
#
set httpdConf = $conf/httpd.conf
/usr/bin/touch $httpdConf
/usr/bin/chmod +rw $httpdConf
echo \# > $httpdConf
echo ServerType standalone >> $httpdConf
echo >> $httpdConf
echo Port $sockPort >> $httpdConf
echo >> $httpdConf
echo User daemon >> $httpdConf
echo Group sys >> $httpdConf
echo >> $httpdConf
echo ServerAdmin @$DT_hostname$mydomain >> $httpdConf
echo ServerName $DT_hostname$mydomain >> $httpdConf
echo >> $httpdConf
echo ServerRoot $wwwRoot >> $httpdConf
echo >> $httpdConf
echo ErrorLog logs/error_log >> $httpdConf
echo TransferLog logs/access_log >> $httpdConf
echo AgentLog logs/agent_log >> $httpdConf
echo RefererLog logs/referer_log >> $httpdConf
echo PidFile logs/httpd.pid >> $httpdConf
echo "httpd server: port $sockPort"
exit 1